package vip.zj.toimage;

import org.apache.commons.io.filefilter.FalseFileFilter;
import vip.zj.utils.VideoUtils;

import java.io.File;
import java.util.Arrays;

import static vip.zj.utils.VideoUtils.getPicFromVideo;

public class VideoToImage {
    public static void main(String[] args) throws Exception {
        String ffmpegUrl = VideoToImage.class.getClassLoader().getResource("static/ffmpeg.exe").getFile();
//        String vp = "D:\\时间分类图片\\9.16\\VID_20210911_160421.mp4";
        String ffp = ffmpegUrl.substring(1);
        String pathUrl="D:\\标注分类\\10.12\\新建文件夹";
        File file = new File(pathUrl);
        File[] files = file.listFiles();
        Arrays.stream(files).forEach(i->{
            try {
                System.out.println(i.getPath());
                getPicFromVideo(ffp, i.getPath(), null, "E:\\picsave");
            } catch (Exception e) {
                e.printStackTrace();
            }
        });

    }

    public static Boolean major(String videoPath,String imgPath){
        String ffmpegUrl = VideoToImage.class.getClassLoader().getResource("static/ffmpeg.exe").getFile();
//        String vp = "D:\\时间分类图片\\9.16\\VID_20210911_160421.mp4";
        String ffp = ffmpegUrl.substring(1);
        String pathUrl=videoPath;
        File file = new File(pathUrl);
        File[] files = file.listFiles();
        Arrays.stream(files).forEach(i->{
            try {
                System.out.println(i.getPath());
                getPicFromVideo(ffp, i.getPath(), null, imgPath);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        return true;
    }
}
